home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 (Special) / OC021.iso / Juegos / King of Skeleton / King of Skeleton.swf / scripts / __Packages / Arr.as next >
Encoding:
Text File  |  2006-02-02  |  1.6 KB  |  87 lines

  1. class Arr extends Array
  2. {
  3.    var iap = 0;
  4.    function Arr()
  5.    {
  6.       super();
  7.       this.splice.apply(this,[0,0].concat(arguments));
  8.    }
  9.    function randInd()
  10.    {
  11.       return Math.floor(Math.random() * this.length);
  12.    }
  13.    function rand()
  14.    {
  15.       return this[Math.floor(Math.random() * this.length)];
  16.    }
  17.    function mean()
  18.    {
  19.       var _loc3_ = 0;
  20.       var _loc4_ = 0;
  21.       var _loc2_ = 0;
  22.       while(_loc2_ < this.length)
  23.       {
  24.          if(!isNaN(Number(this[_loc2_])))
  25.          {
  26.             _loc3_ = _loc3_ + 1;
  27.             _loc4_ += Number(this[_loc2_]);
  28.          }
  29.          _loc2_ = _loc2_ + 1;
  30.       }
  31.       if(_loc3_ > 0)
  32.       {
  33.          return _loc4_ / _loc3_;
  34.       }
  35.       return 0;
  36.    }
  37.    function copy()
  38.    {
  39.       var _loc2_ = new Arr();
  40.       for(var _loc3_ in this)
  41.       {
  42.          _loc2_[_loc3_] = this[_loc3_];
  43.       }
  44.       return _loc2_;
  45.    }
  46.    function current()
  47.    {
  48.       return this[this.iap];
  49.    }
  50.    function next()
  51.    {
  52.       if(this.iap + 1 < this.length)
  53.       {
  54.          this.iap = this.iap + 1;
  55.          return this[this.iap];
  56.       }
  57.       return false;
  58.    }
  59.    function prev()
  60.    {
  61.       if(this.iap > 0)
  62.       {
  63.          this.iap = this.iap - 1;
  64.          return this[this.iap];
  65.       }
  66.       return false;
  67.    }
  68.    function reset()
  69.    {
  70.       if(this.length > 0)
  71.       {
  72.          this.iap = 0;
  73.          return this[this.iap];
  74.       }
  75.       return false;
  76.    }
  77.    function end()
  78.    {
  79.       if(this.length > 0)
  80.       {
  81.          this.iap = this.length - 1;
  82.          return this[this.iap];
  83.       }
  84.       return false;
  85.    }
  86. }
  87.